<?php namespace Admin\Controller; 

use Hdphp\Controller\Controller;
use Admin\Model\Admin;

class LoginController extends Controller
{
	//数据连接驱动
	protected $db;

	//构造函数
	public function __init()
	{
		$this->db = new Admin;	
	}
	
    //动作
    public function login()
    {
    	if (IS_POST) 
    	{
    		if ($this->db->login()) 
            {
               $this->success('登录成功','Index/index');
            }else{
                $this->error($this->db->getError());
            }
    	}else{
           View::make(); 
        }
       
    }

    //验证码方法
    public function code()
    {
        Code::make();
    }

    // 登出方法
    public function out()
    {
        session_unset();
        session_destroy();
        go('login');
    }
}
